%% 生成均值[0,0]，协方差[1,1;1,4]和[1,0;0,4]的二维正态分布
clear all;
clc;

%% 参数初始化
N = 1000;
mu = [0, 0];
sigma1 = [1, 1; 1, 4];
sigma2 = [1, 0; 0, 4];

%% 生成二维正态分布
rng(1);
y1 = mvnrnd(mu, sigma1, N);
y2 = mvnrnd(mu, sigma2, N);

%% 统计样本均值和协方差
meany1 = mean(y1)
cov1 = cov( y1(:,1), y1(:,2) )
meany2 = mean(y2)
cov2 = cov( y2(:,1), y2(:,2) )

%% 画图
% 分开图
figure;
plot(y1(:,1), y1(:,2), '+');
title("E=[0,0] Var=[1,1;1,4]");
figure;
plot(y2(:,1), y2(:,2), '.');
title("E=[0,0] Var=[1,0;0,4]");
% 对比图
figure;
plot(y1(:,1), y1(:,2), '+');
hold on;
plot(y2(:,1), y2(:,2), '.');
title("E=[0,0] Var=[1,1;1,4]vs[1,0;0,4]");
